package com.miracle.mango.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 加入ActiveMQ后，如果不注释会错误，后面再来解决这个问题
 *
 * @author wxf
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//            .apis(RequestHandlerSelectors.basePackage("indi.viyoung.viboot.*"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo1() {
        return new ApiInfoBuilder()
                //标题
                .title("swagger2")
                //描述
                .description("Restful-API-Doc")
                //这里配置的是服务网站，我写的是我的博客园站点~欢迎关注~
                .termsOfServiceUrl("https://www.cnblogs.com/viyoung")
                // 三个参数依次是姓名，个人网站，邮箱
                .contact(new Contact("Vi的技术博客", "https://www.cnblogs.com/viyoung", "18530069930@163.com"))
                //版本
                .version("1.0.0")
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("政府端api")
                .version("1.0.0")
                .build();
    }

}
